import { useEffect } from 'react';
import request from '@/utils/request';
import {formatMoney, formatNumber} from '@/utils';
const Welcome = () => {
  useEffect(() => {
    request
      .post<string>('/api/login', { username: 'admin', password: '123456' })
      .then(res => {
        console.log('res', res);
      })
      .catch(err => {
        // 接口错误要通过catch来捕获
        console.log('err', err);
      });
      getLogin()
  }, []);

  const getLogin = async () => {
    // <string> 泛型接口 用来指定返回的数据类型
    const res = await request.get<string>('/api/login');
    console.log(res, 'res')
  }

  console.log(formatMoney(20520132.123))
  console.log(formatNumber('20520132.123'))
  return (
    <div>
      <h1 className='read-the-docs'>欢迎</h1>
    </div>
  );
};
export default Welcome;
